package com.mall.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * 角色权限的持久化层
 * @author :liangY
 * @date : 2021-01-09 15:50
 */
@Repository
public interface IRolePermissionDao {

    /**
     * 删除角色权限通过id
     * @param role_id
     * @param permission_id
     * @return
     */
    @Delete("delete from tb_role_permission where role_id=#{role_id} and permission_id=#{permission_id}")
    Integer delById(@Param("role_id") Integer role_id,@Param("permission_id") Integer permission_id);

    /**
     * 删除角色权限通过角色id
     * @param role_id
     * @return
     */
    @Delete("delete from tb_role_permission where role_id=#{role_id}")
    Integer delByRoleId(@Param("role_id") Integer role_id);

    /**
     * 添加角色权限通过角色权限id
     * @param role_id
     * @param permission_id
     * @return
     */
    @Insert("insert into tb_role_permission (role_id,permission_id)values(#{role_id},#{permission_id})")
    Integer addById(@Param("role_id") Integer role_id,@Param("permission_id") Integer permission_id);
}
